<?php
include "includes/sesiones.php";
include "includes/comunes.php";

$sql="select * from creditos where id=".$_GET['cre_id'];

$rescre= cons_ins($sql);
$regCred=mysql_fetch_array($rescre);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php include "includes/metas.php";?>

<script language="JavaScript" type="text/javascript" src="combos/jquery.js"></script>
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<link href="modal/styles/modal-window.css" type="text/css" rel="stylesheet" />
<script language="JavaScript" type="text/javascript">
$(function()
{
   $('#verificar').click(function(event) {
        
        var cod = $('[name=codigo]').val();
		var idCli = $('[name=idCli]').val();
		var Cred = $('[name=Cred]').val();
       
	   $('#divver').load('verCodigo.php',{codigo:cod,idCli:idCli,cre:Cred} );
	  
    });
	
	
});
</script>






<style>
#loading
{
	position:absolute;
	top:0px;
	right:0px;
	background:#ff0000;
	color:#fff;
	font-size:14px;
	font-familly:Arial;
	padding:2px;
	display:none;
}
</style>



</head>

<body>
    

<div class="contenedor">
    <div id="loading">abriendo ...</div>
	<div class="cont">
    	<?php include "includes/head.php";?>
        <?php include "includes/menu.php";?>
            
    	<div class="novedadescont">
             <form id="form" name="form" method="post">
        	<div class="novedadestitulo">
            	<div class="menuvolver"> <a href="javascript:history.back(1)">Volver Atrás</a></div>
                
            </div>
			
                 <div class="novedadestitulo">
            	<div class="novetitulo2">Pago de Credito Nº <?php echo $_GET['cre_id'] ?></div>
            </div>
          <?php //if($regCred['estado']==1):?>
           <!--<div id="divver" style=" width:100%;  color:#F00; padding-top: 40px; font-family:Verdana, Geneva, sans-serif; font-weight:bold;" >
                CREDITO PENDIENTE DE APROBACION <input name="codigo" type="text" id="codigo" size="25" />
                <input name="idCli" type="hidden" id="idCli" size="25" value="<?php echo obtener_cliente_id($regCred['cliente'])?>"/>
                <input name="Cred" type="hidden" id="Cred" size="25" value="<?php echo $_GET['cre_id']?>"/>
               <input name="verificar"  id="verificar" type="button" value="Verificar Codigo"  style="border:#F00 1px solid; color:#F00; background-color: #FCC9D0;"/>
               </div>-->
           <?php //endif ?>
            <br /><br />
            
            <div class="formucont">
                
           	  <div class="formlinea">

                <div class="formtxt">Cliente</div>
                <div class="formtxt2">
                    <label for="form"></label>
                    <?php echo obtener_cliente($regCred['cliente'])?>
                  
                </div>
                
                </div>   
                
              <div class="formlinea">
                <div class="formtxt">Dni</div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                    <?php echo $regCred['cliente']?>
                </div>
                
                </div>
			
              <div class="formlinea">
                <div class="formtxt">Tel. Cel.</div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                   <span style="color:green;"> <?php echo obtener_cliente_tel($regCred['cliente'])?></span>
                </div>
                
                </div>		

          <div class="formlinea">
                <div class="formtxt">Tel. Fijo</div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                   <span style="color:green;"> <?php echo obtener_cliente_tel_fijo($regCred['cliente'])?></span>
                </div>
                
                </div>						
                
		 <div class="formlinea">
                <div class="formtxt">Tel. Vecino</div>
                <div class="formtxt2">
                 
                    <label for="form"></label>
                   <span style="color:green;"> <?php echo obtener_cliente_tel_vecino($regCred['cliente'])?></span>
                </div>
                
                </div>						
                		
                
                
            
            
		
                         
            </div>           
            <div class="novedadestitulo">
            	<div class="novetitulo2">Datos del Credito <?php  echo $regCred['id'] ?> con Fecha <?php  echo format_fec($regCred['fecha'],"/") ?></div>
            </div>
           <div class="formlinea">
                <div class="formtxt">Entidad Financiera</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    
                        <?php
                         echo obtener_financiera($regCred['financiera'])

                        ?>
                 
        
                </div>

                </div>

             <div class="formlinea">
                <div class="formtxt">Plan</div>
                <div class="formtxt2">

                 <?php
                         echo obtener_plan($regCred['tipoplan'])

                        ?>

                </div>

                </div>

              <div class="formlinea">
                <div class="formtxt">Tasa</div>
                <div class="formtxt2">

                    <label for="form"></label>

                    <?php
                         echo obtener_tasa_plan($regCred['tipoplan'])

                        ?>

                </div>

                </div>

               <div class="formlinea">
                <div class="formtxt">Amortizacion</div>
                <div class="formtxt2">

                    <label for="form"></label>
                  Simple

                </div>

                </div>

                 <div class="formlinea">
                <div class="formtxt">Autorizacion</div>
                <div class="formtxt2">

                    <label for="form"></label>
                  <?php
                         if($regCred['autorizacion']=="")
                                 echo "S/C";
                              else   
                                 echo $regCred['autorizacion'];

                        ?>

                </div>

                </div>
                   <div class="formlinea">
                <div class="formtxt">Gracia</div>
                <div class="formtxt2">

                    <label for="form"></label>
                  <?php
                         echo obtener_gracia_plan($regCred['tipoplan'])

                        ?>

                </div>

                </div>

                  <div class="formlinea">
                <div class="formtxt">Cuotas</div>
                <div class="formtxt2">

                    <label for="form"></label>
                   <?php
                         echo obtener_cuotas_plan($regCred['tipoplan'])

                        ?>

                </div>

                </div>

                  <div class="formlinea">
                <div class="formtxt">Monto</div>
                <div class="formtxt2">

                    <label for="form"></label>
                  <?php
                         echo "$ ".number_format($regCred['monto'])

                        ?>

                </div>

                </div>

                 <div class="formlinea">
                <div class="formtxt">Dia Vto</div>
                <div class="formtxt2">

                    <label for="form"></label>
                   <?php
                         echo $regCred['diaVto'];

                        ?>

                </div>

                </div>
				
				 <div class="formlinea">
                <div class="formtxt">Entrega</div>
                <div class="formtxt2">

                    <label for="form"></label>
                   <?php
                         echo "$ ".round($regCred['Entrega'],0);

                        ?>

                </div>

                </div>

                  <div class="formlinea">
                <div class="formtxt">Observacion</div>
                <div class="formtxt2">

                    <label for="form"></label>
                    <?php
                         if($regCred['observacion']=="")
                                 echo "- - - ";
                              else
                                 echo $regCred['observacion'];

                        ?>


                </div>

                </div>
            
          <div class="novedadestitulo">
            	<div class="novetitulo2">Detalle de cuotas</div>
            </div>
  <table cellspacing="0" cellpadding="4" border="0" id="tblTabla"  style="color: #333333;
        width: 100%; border-collapse: collapse;">
        <tr style="color:#000; font-weight: bold;font-family: Tahoma; background-color:#666;">
            <th align="left">
                Nro
            </th>
            <th align="center">
                Fecha. Vto.
            </th>
             <th align="center">
                Capital
            </th>
            <th align="center" scope="col">
                Interes
            </th>
            <th align="center" scope="col">
                Punitorios
            </th>
              <th align="center" scope="col">
                Total Abonado
            </th>
            <th align="center" scope="col">
                Saldo Cta
            </th>
        </tr>
<?php
$sqldet="select * from cuotasCredito where creditoId=".trim($_GET['cre_id']);
//echo $sqldet;
$resdet=  cons_ins($sqldet);
while ($regdet=mysql_fetch_array($resdet)):
?>


      <tr>
      <td align="left" style="font-family: Tahoma;"><?php echo $regdet['cuota'];?></td>
      <td align="center" style="font-family: Tahoma;"><?php echo format_fec($regdet['vencimiento'],"/");?></td>
      <td align="center" style="font-family: Tahoma;">$ <?php echo round($regdet['capital']);?></td>
      <td align="center" style="font-family: Tahoma;">$ <?php echo round($regdet['intereses']);?></td>
       
      <td align="center" style="font-family: Tahoma;">$ <?php 
      if(($regdet['saldo']>0) and ($regdet['vencimiento'] < date("Y-m-d"))){
       $pun=  obtener_punitorios(obtener_tasa_punitorios($regCred['tipoCredito']), $regdet['vencimiento'], $regdet['saldo']);
 
       echo round(obtener_punitorios(obtener_tasa_punitorios($regCred['tipoCredito']), $regdet['vencimiento'], $regdet['saldo']),0);
      }
       else{
        $pun=  $regdet['punitorios'];
        echo round($regdet['punitorios'],0);
      }
      ?></td>
      <td align="center" style="font-family: Tahoma;">$ <?php 
      if($regdet['estado']==2)
            echo 0;
      else
           echo round(sumar_recibos($regCred['id'], $regdet['cuota']),0);

      ?></td>
      <td align="center" style="font-family: Tahoma;">$ <?php 
	  if($regdet['estado']==2)
	  echo round($regdet['saldo'],0);
	  else
	  echo round($regdet['saldo']+$pun,0);
	  
	  ?></td>
      <td align="center" style="font-family: Tahoma;">
          <?php if(($regdet['saldo']>1) and  ($regCred['estado']<> 3))://Verifico si el credito tiene salgo pero No esta anulado?>
          <a  target="new" href="pagar.php?cre_id=<?php echo $regCred['id']?>&cuota=<?php echo $regdet['cuota']?>&total=<?php echo $regdet['intereses']+$regdet['capital'];?>&pun=<?php echo $pun ?>" onclick="$(this).modal({width:833, height:453}).open(); return false;"><img src="images/btpagar.png" border="0" width="25px"/></a>
          <?php if(round(sumar_recibos($regCred['id'], $regdet['cuota']),0)>1 ):?>
		 <a  href="ImprimirPagoCuota.php?cre_id=<?php echo $regCred['id'];?>&cuota=<?php echo $regdet['cuota'];?>"  target="_blank"  style="width:200px; border-left: 300px;">
                <img src="images/imprimir.png" width="25px" border="0"/></a>
		 <?php endif ?>
		<?php
          elseif(($regdet['saldo']>1) and  ($regCred['estado']== 3))://Verifico si el credito tiene salgo pero esta anulado
              echo "Anulado";
          else:

              echo obtener_estado($regdet['estado'])?>
			  <a  href="ImprimirPagoCuota.php?cre_id=<?php echo $regCred['id'];?>&cuota=<?php echo $regdet['cuota'];?>"  target="_blank"  style="width:200px; border-left: 300px;">
                <img src="images/imprimir.png" width="25px" border="0"/></a>
          <?php endif ?>

    </td>

      </tr>
<?php

endwhile
?>

    </table>


        	<div class="novedadesbottom"></div>
                </form>
        </div>
    
    
    
    
    <div class="separador"></div>
<?php include "includes/menufooter.php";?>
    
    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>

 
</div>
 <script type="text/javascript" language="javascript" src="modal/scripts/jquery-1.3.2.min.js"></script>
		<script type="text/javascript" language="javascript" src="modal/scripts/modal-window.min.js"></script>   
</body>
</html>
